package com.wthink.newMain.settings.menuManager.inner.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.wthink.hzgj.data.Result
import com.wthink.hzgj.data.domain.DeviceVol
import com.wthink.hzgj.service.DevService
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

class MenuManagerSystemViewmodel : ViewModel() {

    val devVol = MutableLiveData<DeviceVol>()
    val inVol = MutableLiveData<Int>()
    val outVol = MutableLiveData<Int>()
    val micVol = MutableLiveData<Int>()
    val light = MutableLiveData<Int>()
    val screenVol = MutableLiveData<Int>()

    fun setVol() {
        viewModelScope.launch(Dispatchers.IO) {
            val ret = DevService.setVol(inVol.value!!, outVol.value!!, micVol.value!!)
        }
    }

    fun getDevVol(type: String) {
        viewModelScope.launch(Dispatchers.IO) {
            val ret = DevService.getDevVol(type)
            if (ret is Result.Success) {
                devVol.postValue(ret.data)
            }
        }
    }
}